package com.atguigu.guli.gmall.gateway.filter;

import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
//@Component
public class TestGlobalFilter implements GlobalFilter {
    //过滤方法：全局过滤器每个请求都会进过过滤方法处理
    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        /*
        exchange:交换机对象
                包含请求报文对象 和 服务器响应对象
        chain：filter链对象
         */
        System.out.println("TestGlobalFilter全局过滤器过滤所有请求");
        //放行
        return chain.filter(exchange);
    }
}
